Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate PRs FoundThis PR appears to be directly related to previous Windows PowerShell UTF-8 encoding fixes:
Why they're related: All three PRs address the same core issue—fixing UTF-8 encoding problems for PowerShell output on Windows. PR #49012 mentions it's related to issues #30205 and #30055, and appears to implement a similar fix by injecting You should verify whether these previous PRs already resolved the issue or if this is addressing a gap they missed. |
Windows PowerShell 5.1 encodes its stdout with the legacy OEM code page (e.g. CP936 on zh-CN systems) when output is redirected, while opencode decodes process output as UTF-8, producing mojibake for any non-ASCII shell output. Prepend a [Console]::OutputEncoding/$OutputEncoding UTF-8 preamble to PowerShell commands spawned by the shell tool and bang commands on Windows. Permission scanning and command titles still use the original command text since the preamble is injected at spawn time. Corresponds to upstream discussion in anomalyco#23636.
8aef152 to
042190d
Compare
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #30205
Related: #30055, #23636
Type of change
What does this PR do?
解决Windows下,opencode中模型使用powershell输出中文时会出现乱码的问腿
How did you verify your code works?
在中文 Windows 11 + PowerShell 5.1 环境下,用与工具相同的方式启动 PowerShell(管道输出 stdout),会得到 GBK 编码字节(b2e2 cad4 ...),证实了乱码的原因是编码不匹配,修复后,用重新构建的二进制做端到端测试,让模型执行 echo 测试中文:你好世界——打补丁前输出乱码,打补丁后能正确显示中文。


修复前后对比如下:
Checklist